<?php
	function openConnection()
	{
		$cn = mysql_connect(SERVER, USER, PASSWORD);
		if(!$cn)
			die(mysql_error());
		else
			selectDatabase();
			//show khmer unicode 
			mysql_query("SET character_set_results=utf8",$cn); mb_language('uni'); 
			mb_internal_encoding('UTF-8'); 
			mysql_select_db("mannainv", $cn);
			mysql_query("set names 'utf8'",$cn);
	}
	function selectDatabase()
	{
		if(!mysql_select_db(DB))
			die(mysql_error());
	}
	function query($sql)
	{
		$result = mysql_query($sql);
		if(!$result)
		{
			errorMessage("Execute SQL Statement failed. Last SQL Statement: " . $sql 
				. "<br /> MySQL Said: " . mysql_error());	
		}
		return $result;
	}
	function fetch_row($result)
	{
		return mysql_fetch_row($result);	
	}
	function fetch_assoc($result)
	{
		return mysql_fetch_assoc($result);	
	}
	function fetch_array($result)
	{
		return mysql_fetch_array($result);	
	}
	function num_rows($result)
	{
		return mysql_num_rows($result);	
	}
	function fetch_object($result)
	{
		return mysql_fetch_object($result);	
	}
	function closeConnection()
	{
		mysql_close();
	}
?>